﻿<UserControl x:Class="NicoView.View.NicoViewBroadcastConsolControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:view="clr-namespace:NicoView.View"
             mc:Ignorable="d" 
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             d:DesignHeight="500" d:DesignWidth="500" DataContext="{Binding NicoViewBroadcastConsolViewModel, Mode=OneWay, Source={StaticResource locator}}"
             
             >

    
    

    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="5"/>        
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="5"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="5"/>
            <ColumnDefinition Width="150"/>
            <ColumnDefinition Width="5"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="5"/>
        </Grid.ColumnDefinitions>




        <ListBox Grid.Row="1" Grid.RowSpan="2"  IsTabStop="False"  HorizontalContentAlignment="Left" HorizontalAlignment="Stretch"  IsSynchronizedWithCurrentItem="True"  Grid.Column="1" x:Name="BroadcastList" ItemsSource="{Binding Controllers}" SelectedItem="{Binding CurrentController}"   >

            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="IsTabStop" Value="False"/>

                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    
                    <StackPanel>
                        <TextBlock x:Name="ControllerLabel" Text="{Binding Title}" >

                            <TextBlock.Style>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Title.Count}" Value="0">
                                            <Setter Property="Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>


                        </TextBlock>
                        
                        <TextBlock Text="{Binding NotSetTitle, Mode=OneWay, Source={StaticResource resources}}" >
                            
                            <TextBlock.Style>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Title.Count}" Value="0">
                                            <Setter Property="Visibility" Value="Visible"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>
                    </StackPanel>
                    
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox> 
        
        <Grid Grid.Row="2"  Grid.Column="1" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            
            <Button Grid.Column="0" Content="{Binding Add, Mode=OneWay, Source={StaticResource resources}}" Command="{Binding AddControllerCommand, Mode=OneWay}"/>
            
            <Button Grid.Column="1" Content="{Binding Delete, Mode=OneWay, Source={StaticResource resources}}" Command="{Binding RemoveControllerCommand, Mode=OneWay}" CommandParameter="{Binding CurrentController}"/>
            
            <Button Grid.Column="2" Content="{Binding Clone, Mode=OneWay, Source={StaticResource resources}}" Command="{Binding CopyControllerCommand, Mode=OneWay}" CommandParameter="{Binding CurrentController}" />
        </Grid>
        <GridSplitter IsTabStop="False" Grid.Row="1" Grid.Column="2"  VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="5" ResizeDirection="Columns"  />

        <Grid Grid.Row="1" Grid.RowSpan="2" Grid.Column="3"  >
            
            
            
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Grid.Style>
                <Style TargetType="{x:Type Grid}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding CurrentController}" Value="{x:Null}">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Grid.Style>

            <ScrollViewer Grid.Row="0"  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
                <view:NicoViewBroadcastSelectedControl DataContext="{Binding CurrentController}"  />
            </ScrollViewer>





            <Button x:Name="StartBroadcastButton" Grid.Row="1"   Command="{Binding StartBroadcastCommand}"  Margin="5" Content="{Binding BroadcastThisSetting, Mode=OneWay, Source={StaticResource resources}}" FontSize="24" FontWeight="Bold" />
        </Grid>
        

    </Grid>


    
</UserControl>
